import xlrd


def read_xls(filename, sheetIndex, colIndex):
    wb = xlrd.open_workbook(filename)

    table = wb.sheets()[sheetIndex]

    return table.col_values(colIndex)


def write_to_js(filename, data1, data2, data3):
    my_open = open(filename, 'w')
    my_open.write('var firstList = [')

    for item in data1:
        my_open.write('{\'name\':\'' + item + '\'},')

    my_open.write('];')
    
    my_open.write('var secondList = [')

    for item in data2:
        my_open.write('{\'name\':\'' + item + '\'},')

    my_open.write('];')

    my_open.write('var thirdList = [')

    for item in data3:
        my_open.write('{\'name\':\'' + item + '\'},')

    my_open.write('];')


    my_open.close()

    my_open = open(filename, 'r')

    my_infor = my_open.readlines()
    my_open.close()
    print(my_infor)


data1 = read_xls('1.xls', 0, 0)
data2 = read_xls('2.xls', 0, 0)
data3 = read_xls('3.xls', 0, 0)

write_to_js('conf.js', data1, data2, data3)